<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('sso_id', 64)->nullable()->comment('统一登录用户ID');
            $table->string('user_id')->nullable()->comment('业务系统中用户ID');
            $table->string('name')->nullable()->comment('用户名称');
            $table->tinyInteger('gender')->default(0)->comment('性别 0 未知 1 男 2 女');
            $table->string('username')->comment('用户登录账号');
            $table->string('password')->comment('用户登录密码');
            $table->tinyInteger('password_status')->default(0)->comment('用户密码状态');
            $table->string('wx_oa_openid')->nullable()->comment('微信公众号openid');
            $table->string('wx_mp_openid')->nullable()->comment('微信小程序openid');
            $table->tinyInteger('status')->default(1)->comment('1启用0禁用');
            $table->string('last_ip', 16)->nullable()->comment('最后登录IP');
            $table->dateTime('last_time')->nullable()->comment('最后登录时间');
            $table->tinyInteger('is_admin')->default(0)->comment('1管理员0普通');
            $table->string('identifiable_type')->nullable()->comment('身份类型');
            $table->string('org_no')->nullable()->comment('所属组织编码');
            $table->softDeletes();
            $table->timestamps();
            $table->comment('用户表');
//
//            $table->string('email')->unique();
//            $table->timestamp('email_verified_at')->nullable();
//            $table->string('password');
//            $table->rememberToken();
        });

        /**
         * CREATE TABLE `manage` (
            `manage_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '管理员ID',
            `org_id` int(11) DEFAULT '0' COMMENT '机构ID',
            `org_no` varchar(20) NOT NULL COMMENT '机构编码',
            `user_name` varchar(32) NOT NULL COMMENT '用户登录昵称',
            `user_pwd` char(32) NOT NULL COMMENT '密码',
            `real_name` varchar(64) NOT NULL DEFAULT '' COMMENT '姓名',
            `role_ids` varchar(50) DEFAULT '0' COMMENT '角色ID',
            `role_names` varchar(255) DEFAULT NULL COMMENT '角色名称',
            `status` tinyint(1) DEFAULT '1' COMMENT '1启用0禁用',
            `is_delete` tinyint(1) DEFAULT '0' COMMENT '1伪删除',
            `last_ip` varchar(16) DEFAULT NULL COMMENT '上次登陆IP',
            `last_time` int(11) DEFAULT NULL COMMENT '上次登陆时间',
            `is_admin` tinyint(1) DEFAULT '0' COMMENT '1超管',
            `is_developer` tinyint(1) DEFAULT '0' COMMENT '1开发者',
            `is_schadmin` tinyint(1) DEFAULT '0' COMMENT '1校管理',
            `updated_at` int(11) DEFAULT NULL COMMENT '更新时间',
            `created_at` int(11) DEFAULT NULL COMMENT '添加时间',
            `phone` varchar(16) DEFAULT NULL COMMENT '电话',
            `sex` tinyint(4) NOT NULL DEFAULT '0' COMMENT '性别码',
            PRIMARY KEY (`manage_id`),
            KEY `org_no` (`org_no`)
            ) ENGINE=InnoDB AUTO_INCREMENT=4680 DEFAULT CHARSET=utf8mb4 COMMENT='管理员表';
         *
         *
         */
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('users');
    }
};
